<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<script type="text/javascript">
    $(document).ready(function () {
        var currentId = Page.currentId;
        var count = 0;
        var sysInfo_plmn;
        var loading = '-';

        function loadPage() {

            Page.postJSON({
                json: { cmd: RequestCmd.SYS_INFO },
                success: function (datas) {
                    var data2 = datas.data,
                        data_wan = data2.wan,
                        data_4g = data2['4g'],
                        data_4g1 = data2['4g1'],
                        data_4g2 = data2['4g2'],
                        names_wan = [],
                        values_wan = [],
                        names_4g = [],
                        values_4g = [],
                        names_4g1 = [],
                        values_4g1 = [],
                        names_4g2 = [],
                        values_4g2 = [];
                    Page.isNULLToSpace = true;
                    if (!!data_wan.ipaddr) {

                        names_wan.push(DOC.net.mac);
                        values_wan.push(data_wan.mac || loading);

                        names_wan.push(DOC.net.ip);
                        values_wan.push(data_wan.ipaddr || loading);

                        names_wan.push(DOC.net.mask);
                        values_wan.push(data_wan.netmask || loading);

                        names_wan.push(DOC.net.gateway);
                        values_wan.push(data_wan.gateway || loading);

                        names_wan.push(DOC.net.dns1);
                        names_wan.push(DOC.net.dns2);
                        values_wan.push(data_wan.first_dns || loading);
                        values_wan.push(data_wan.second_dns || loading);

                        names_wan.push(DOC.net.rxPackets);
                        values_wan.push(data_wan.rx_packets || loading);

                        names_wan.push(DOC.net.rxBytes);
                        values_wan.push(data_wan.rx_bytes || loading);

                        names_wan.push(DOC.net.txPackets);
                        values_wan.push(data_wan.tx_packets || loading);

                        names_wan.push(DOC.net.txBytes);
                        values_wan.push(data_wan.tx_bytes || loading);

                        names_wan.push(DOC.net.interface);
                        values_wan.push(data_wan.interface || loading);

                        var wan_html = Page.createTable2(DOC.title.wan, names_wan, values_wan, names_wan.length, 1).replace("<td>", "<td>");
                        $('#wan_info').html(wan_html);
                        Page.setStripeTable();
                    }

                    if (data_4g != undefined) {

                        // names_4g.push(DOC.net.mac);
                        // values_4g.push(data_4g.mac || loading);

                        names_4g.push(DOC.net.ip);
                        values_4g.push(data_4g.ipaddr || loading);

                        names_4g.push(DOC.net.mask);
                        values_4g.push(data_4g.netmask || loading);

                        names_4g.push(DOC.net.gateway);
                        values_4g.push(data_4g.gateway || loading);

                        names_4g.push(DOC.net.dns1);
                        names_4g.push(DOC.net.dns2);
                        values_4g.push(data_4g.first_dns || loading);
                        values_4g.push(data_4g.second_dns || loading);

                        names_4g.push(DOC.net.rxPackets);
                        values_4g.push(data_4g.rx_packets || loading);

                        names_4g.push(DOC.net.rxBytes);
                        values_4g.push(data_4g.rx_bytes || loading);

                        names_4g.push(DOC.net.txPackets);
                        values_4g.push(data_4g.tx_packets || loading);

                        names_4g.push(DOC.net.txBytes);
                        values_4g.push(data_4g.tx_bytes || loading);

                        names_4g.push(DOC.net.interface);
                        values_4g.push(data_4g.interface || loading);

                        var wan_html = Page.createTable2(DOC.title.apn, names_4g, values_4g, names_4g.length, 1).replace("<td>", "<td>");
                        $('#4g_info').html(wan_html);
                        Page.setStripeTable();
                    }

                    Page.postJSON({
                        json: {
                            cmd: RequestCmd.GET_APN_CONFIG
                        },
                        success: function (data) {
                            var apnData1 = data.data[1];
                            var apnData2 = data.data[2];
                            if (apnData1.enable == "1") {
                                if (data_4g1 != undefined) {

                                    // names_4g1.push(DOC.net.mac);
                                    // values_4g1.push(data_4g1.mac || loading);

                                    names_4g1.push(DOC.net.ip);
                                    values_4g1.push(data_4g1.ipaddr || loading);

                                    names_4g1.push(DOC.net.mask);
                                    values_4g1.push(data_4g1.netmask || loading);

                                    names_4g1.push(DOC.net.gateway);
                                    values_4g1.push(data_4g1.gateway || loading);

                                    names_4g1.push(DOC.net.dns1);
                                    names_4g1.push(DOC.net.dns2);
                                    values_4g1.push(data_4g1.first_dns || loading);
                                    values_4g1.push(data_4g1.second_dns || loading);

                                    names_4g1.push(DOC.net.rxPackets);
                                    values_4g1.push(data_4g1.rx_packets || loading);

                                    names_4g1.push(DOC.net.rxBytes);
                                    values_4g1.push(data_4g1.rx_bytes || loading);

                                    names_4g1.push(DOC.net.txPackets);
                                    values_4g1.push(data_4g1.tx_packets || loading);

                                    names_4g1.push(DOC.net.txBytes);
                                    values_4g1.push(data_4g1.tx_bytes || loading);

                                    names_4g1.push(DOC.net.interface);
                                    values_4g1.push(data_4g1.interface || loading);

                                    var wan_html = Page.createTable2(DOC.title.apn1, names_4g1, values_4g1, names_4g1.length, 1).replace("<td>", "<td>");
                                    $('#4g1_info').html(wan_html);
                                    Page.setStripeTable();
                                }
                            }

                            if (apnData2.enable == "1") {
                                if (data_4g2 != undefined) {

                                    // names_4g2.push(DOC.net.mac);
                                    // values_4g2.push(data_4g2.mac || loading);

                                    names_4g2.push(DOC.net.ip);
                                    values_4g2.push(data_4g2.ipaddr || loading);

                                    names_4g2.push(DOC.net.mask);
                                    values_4g2.push(data_4g2.netmask || loading);

                                    names_4g2.push(DOC.net.gateway);
                                    values_4g2.push(data_4g2.gateway || loading);

                                    names_4g2.push(DOC.net.dns1);
                                    names_4g2.push(DOC.net.dns2);
                                    values_4g2.push(data_4g2.first_dns || loading);
                                    values_4g2.push(data_4g2.second_dns || loading);

                                    names_4g2.push(DOC.net.rxPackets);
                                    values_4g2.push(data_4g2.rx_packets || loading);

                                    names_4g2.push(DOC.net.rxBytes);
                                    values_4g2.push(data_4g2.rx_bytes || loading);

                                    names_4g2.push(DOC.net.txPackets);
                                    values_4g2.push(data_4g2.tx_packets || loading);

                                    names_4g2.push(DOC.net.txBytes);
                                    values_4g2.push(data_4g2.tx_bytes || loading);

                                    names_4g2.push(DOC.net.interface);
                                    values_4g2.push(data_4g2.interface || loading);

                                    var wan_html = Page.createTable2(DOC.title.apn2, names_4g2, values_4g2, names_4g2.length, 1).replace("<td>", "<td>");
                                    $('#4g2_info').html(wan_html);
                                    Page.setStripeTable();    
                                }
                            }
                        }
                    })

                    Page.isNULLToSpace = false;
                }
            });

        }



        loadPage();

        if(window.timeoutStartWan) {
            window.timeWan = setInterval(function() {
                loadPage()
            }, 10000)
        }

        Page.getHelperPage('html/info/wanInfo.html');
        $('.helper_box').show();

    });



</script>

<div class="detail_box" style="width:60%;float:left;">
    <div id="net_info"></div>
    <div id="wan_info" style="margin-left:20px"></div>
    <div id="4g_info" style="margin-left:20px"></div>
    <div id="4g1_info" style="margin-left:20px"></div>
    <div id="4g2_info" style="margin-left:20px"></div>
</div>

<div class="helper_box">
    <div id="helper"></div>
</div>